<!--{template /module/admin/view/head}-->
<style type="text/css">
    #div_block_list .btn {text-shadow:none;}
</style>
<div id="left_layout">
    <div id="main_content" class="container-fluid">
        <!--{template /module/admin/view/head_nav}-->
        <div class="row-fluid">
            <div class="well widget">
                <div class="widget-content">
                    <form id="frm_grid" name="frmGrid" action="{$ADMIN_SCRIPT}/admin/file/_ilinei&frame=content&file={$_var[gp_file]}&path={$_var[gp_path]}" method="post">
                        <input type="hidden" name="formsubmit" value="yes" />
                        <fieldset>
                            <textarea name="txtContent" id="txt_content" style="width:98%; background:#f3f3f3; color:#008200;" rows="16" cols="80">{$file[content]}</textarea>
                        </fieldset>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<textarea id="txt_block_list" style="display:none;">
	<div id="div_block_list">
        <button class="btn btn-small btn-choice btn-inverse" rel="file" params="">{lang admin.ilinei.frame_parser.view.button.file}</button>
        <button class="btn btn-small btn-choice" rel="cms__category_multi" params="">{lang admin.ilinei.frame_parser.view.button.category.multi}</button>
        <button class="btn btn-small btn-choice" rel="cms__category_crumbs" params="">{lang admin.ilinei.frame_parser.view.button.category.crumbs}</button>
        <button class="btn btn-small btn-choice" rel="cms__category_one" params="">{lang admin.ilinei.frame_parser.view.button.category.one}</button>
        <button class="btn btn-small btn-choice" rel="cms__article_multi" params="">{lang admin.ilinei.frame_parser.view.button.article.multi}</button>
        <button class="btn btn-small btn-choice" rel="cms__article_one" params="">{lang admin.ilinei.frame_parser.view.button.article.one}</button>

        <hr/>
        <div class="block" id="block-file">
            <p class="blocks">
                <!--{code $loop = 0;}-->
                <!--{loop $pages $key $item}-->
                <!--{if $item['type'] == 'block'}-->
                <label class="checkbox">
                    <input class="fancy" name="rdoBlock" type="radio" value="{$item[file]}" {if $loop == 0}checked="checked"{/if}/> {$item[name]}
                </label>
                <!--{code $loop = $loop + 1;}-->
                <!--{/if}-->
                <!--{/loop}-->
            </p>
        </div>
        <div class="block" id="block-cms__category_multi" style="display:none;">
            <table>
                <tr>
                    <td><label>{lang admin.ilinei.frame_parser.view.category.multi.identity.label} *</label></td>
                    <td>
                        <input type="text" class="input-medium" name="txtIdentity" placeholder="{lang admin.ilinei.frame_parser.view.category.multi.identity.placeholder}..." maxlength="20" value="00" />
                        <span class="help-inline">{lang admin.ilinei.frame_parser.view.category.multi.identity.tips}</span>
                    </td>
                </tr>
                <tr>
                    <td><label>{lang admin.ilinei.frame_parser.view.category.multi.var.label}</label></td>
                    <td>
                        <input type="text" class="input-medium" name="txtVar" placeholder="{lang admin.ilinei.frame_parser.view.category.multi.var.placeholder}..." maxlength="10" value="categories" />
                        <span class="help-inline">{lang admin.ilinei.frame_parser.view.category.multi.var.tips}</span>
                    </td>
                </tr>
            </table>
        </div>
        <div class="block" id="block-cms__category_crumbs" style="display:none;">
            <table>
                <tr>
                    <td><label>{lang admin.ilinei.frame_parser.view.category.crumbs.identity.label} *</label></td>
                    <td>
                        <input type="text" class="input-medium" name="txtIdentity" placeholder="{lang admin.ilinei.frame_parser.view.category.crumbs.identity.placeholder}..." maxlength="20" value="00" />
                        <span class="help-inline">{lang admin.ilinei.frame_parser.view.category.crumbs.identity.tips}</span>
                    </td>
                </tr>
                <tr>
                    <td><label>{lang admin.ilinei.frame_parser.view.category.crumbs.var.label}</label></td>
                    <td>
                        <input type="text" class="input-medium" name="txtVar" placeholder="{lang admin.ilinei.frame_parser.view.category.crumbs.var.placeholder}..." maxlength="10" value="crumbs" />
                        <span class="help-inline">{lang admin.ilinei.frame_parser.view.category.crumbs.var.tips}</span>
                    </td>
                </tr>
            </table>
        </div>
        <div class="block" id="block-cms__category_one" style="display:none;">
            <table>
                <tr>
                    <td><label>{lang admin.ilinei.frame_parser.view.category.one.param.label} *</label></td>
                    <td>
                        <input type="text" class="input-medium" name="txtParam" placeholder="{lang admin.ilinei.frame_parser.view.category.one.param.placeholder}..." maxlength="50" value="id" />
                        <span class="help-inline">{lang admin.ilinei.frame_parser.view.category.one.param.tips}</span>
                    </td>
                </tr>
                <tr>
                    <td><label>{lang admin.ilinei.frame_parser.view.category.one.type.label}</label></td>
                    <td>
                        <input type="text" class="input-medium" name="txtType" placeholder="{lang admin.ilinei.frame_parser.view.category.one.type.placeholder}..." maxlength="20" value="" />
                        <span class="help-inline">{lang admin.ilinei.frame_parser.view.category.one.type.tips}</span>
                    </td>
                </tr>
                <tr>
                    <td><label>{lang admin.ilinei.frame_parser.view.category.one.var.label}</label></td>
                    <td>
                        <input type="text" class="input-medium" name="txtVar" placeholder="{lang admin.ilinei.frame_parser.view.category.one.var.placeholder}..." maxlength="10" value="category" />
                        <span class="help-inline">{lang admin.ilinei.frame_parser.view.category.one.var.tips}</span>
                    </td>
                </tr>
            </table>
        </div>
        <div class="block" id="block-cms__article_multi" style="display:none;">
            <table>
                <tr>
                    <td><label>{lang admin.ilinei.frame_parser.view.article.multi.identity.label} *</label></td>
                    <td>
                        <input type="text" class="input-medium" name="txtIdentity" placeholder="{lang admin.ilinei.frame_parser.view.article.multi.identity.placeholder}..." maxlength="20" value="00" />
                        <span class="help-inline">{lang admin.ilinei.frame_parser.view.article.multi.identity.tips}</span>
                    </td>
                </tr>
                <tr>
                    <td><label>{lang admin.ilinei.frame_parser.view.article.multi.param.label}</label></td>
                    <td>
                        <input type="text" class="input-medium" name="txtParam" placeholder="{lang admin.ilinei.frame_parser.view.article.multi.param.placeholder}..." maxlength="50" value="" />
                        <span class="help-inline">{lang admin.ilinei.frame_parser.view.article.multi.param.tips}</span>
                    </td>
                </tr>
                <tr>
                    <td><label>{lang admin.ilinei.frame_parser.view.article.multi.limit.label} *</label></td>
                    <td>
                        <input type="text" class="input-medium" name="txtLimit" placeholder="{lang admin.ilinei.frame_parser.view.article.multi.limit.placeholder}..." maxlength="3" value="10" />
                        <span class="help-inline">{lang admin.ilinei.frame_parser.view.article.multi.limit.tips}</span>
                    </td>
                </tr>
                <tr>
                    <td><label>{lang admin.ilinei.frame_parser.view.article.multi.pager.label}</label></td>
                    <td>
                        <label class="checkbox inline">
                            <input name="cbxPager" type="checkbox" class="fancy" value="1" checked="checked"/> {lang admin.ilinei.frame_parser.view.article.multi.pager.checkbox}
                        </label>
                    </td>
                </tr>
                <tr>
                    <td><label>{lang admin.ilinei.frame_parser.view.article.multi.var.label}</label></td>
                    <td>
                        <input type="text" class="input-medium" name="txtVar" placeholder="{lang admin.ilinei.frame_parser.view.article.multi.var.placeholder}..." maxlength="10" value="articles" />
                        <span class="help-inline">{lang admin.ilinei.frame_parser.view.article.multi.var.tips}</span>
                    </td>
                </tr>
            </table>
        </div>
        <div class="block" id="block-cms__article_one" style="display:none;">
            <table>
                <tr>
                    <td><label>{lang admin.ilinei.frame_parser.view.article.one.param.label} *</label></td>
                    <td>
                        <input type="text" class="input-medium" name="txtParam" placeholder="{lang admin.ilinei.frame_parser.view.article.one.param.placeholder}..." maxlength="20" value="id" />
                        <span class="help-inline">{lang admin.ilinei.frame_parser.view.article.one.param.tips}</span>
                    </td>
                </tr>
                <tr>
                    <td><label>{lang admin.ilinei.frame_parser.view.article.one.var.label}</label></td>
                    <td>
                        <input type="text" class="input-medium" name="txtVar" placeholder="{lang admin.ilinei.frame_parser.view.article.one.var.placeholder}..." maxlength="10" value="article" />
                        <span class="help-inline">{lang admin.ilinei.frame_parser.view.article.one.var.tips}</span>
                    </td>
                </tr>
            </table>
        </div>
        <br/>
    </div>
</textarea>

<script>
    $(function(){
        $('.fancy').uniform();

        $('#txt_content').css('height', ($(document).height() - 100) + 'px');
    });

    function save(){
        $.dialog({submit:'{lang admin.ilinei.frame_parser.view.submit}', message:'<p>{lang admin.ilinei.frame_parser.view.submit.message}</p>', callback:function(){
            $('#modal_dialog .btn-primary').click(function(){
                $('#frm_grid').attr('action', '{$ADMIN_SCRIPT}/admin/file/_ilinei&frame=content&file={$_var[gp_file]}&path={$_var[gp_path]}');
                $('#frm_grid').submit();
            });
        }});
    }

    function block_add(){
        $.dialog({title:'{lang admin.ilinei.frame_parser.view.block.title}', width:800, submit:'{lang admin.ilinei.frame_parser.view.block.add}', message:$('#txt_block_list').val(), callback:function(){
            $('#modal_dialog .fancy').uniform();

            $('#modal_dialog .btn-choice').click(function(){
                $('#modal_dialog .btn-choice').removeClass('btn-inverse');
                $(this).addClass('btn-inverse');

                $('#div_block_list .block').hide();
                $('#block-' + $(this).attr('rel')).show();
            });

            $('#modal_dialog .btn-primary').click(function(){
                //检查是否选了。
                var rel = $('#div_block_list .btn-inverse').attr('rel');
                if(!rel) return;

                var block = '';

                if(rel == 'file'){
                    block += '<' + '!--{';
                    block += 'block file="' + $("#block-" + rel + " input[name='rdoBlock']:checked").val() + '"';
                    block += '/}-->';
                    block += "\r\n";
                }else if(rel == 'cms__category_multi'){
                    block += '<' + '!--{';
                    block += 'block model="\\cms\\_category" method="multi"';

                    block += ' identity="' + $("#block-" + rel + " input[name='txtIdentity']").val() + '"';
                    block += ' var="' + $("#block-" + rel + " input[name='txtVar']").val() + '"';
                    block += '}-->';
                    block += "\r\n";
                    block += "{lang admin.ilinei.frame_parser.view.category.block.content}";
                    block += "\r\n";
                    block += '<' + '!--{';
                    block += '/' + 'block';
                    block += '}-->';
                    block += "\r\n";
                }else if(rel == 'cms__category_crumbs'){
                    block += '<' + '!--{';
                    block += 'block model="\\cms\\_category" method="crumbs"';

                    block += ' identity="' + $("#block-" + rel + " input[name='txtIdentity']").val() + '"';
                    block += ' var="' + $("#block-" + rel + " input[name='txtVar']").val() + '"';
                    block += '}-->';
                    block += "\r\n";
                    block += "{lang admin.ilinei.frame_parser.view.category.block.content}";
                    block += "\r\n";
                    block += '<' + '!--{';
                    block += '/' + 'block';
                    block += '}-->';
                    block += "\r\n";
                }else if(rel == 'cms__category_one'){
                    block += '<' + '!--{';
                    block += 'block model="\\cms\\_category" method="multi"';

                    block += ' param="' + $("#block-" + rel + " input[name='txtParam']").val() + '"';
                    if($("#block-" + rel + " input[name='txtType']").val()) block += ' type="' + $("#block-" + rel + " input[name='txtType']").val() + '"';
                    block += ' var="' + $("#block-" + rel + " input[name='txtVar']").val() + '"';
                    block += '}-->';
                    block += "\r\n";
                    block += "{lang admin.ilinei.frame_parser.view.category.block.content}";
                    block += "\r\n";
                    block += '<' + '!--{';
                    block += '/' + 'block';
                    block += '}-->';
                    block += "\r\n";
                }else if(rel == 'cms__article_multi'){
                    block += '<' + '!--{';
                    block += 'block model="\\cms\\_article" method="multi"';

                    block += ' identity="' + $("#block-" + rel + " input[name='txtIdentity']").val() + '"';
                    if($("#block-" + rel + " input[name='txtParam']").val()) block += ' param="' + $("#block-" + rel + " input[name='txtParam']").val() + '"';
                    block += ' limit="' + $("#block-" + rel + " input[name='txtLimit']").val() + '"';

                    if($("#block-" + rel + " input[name='cbxPager']:checked").length > 0) block += ' pager="true"';

                    block += ' var="' + $("#block-" + rel + " input[name='txtVar']").val() + '"';
                    block += '}-->';
                    block += "\r\n";
                    block += "{lang admin.ilinei.frame_parser.view.article.block.content}";
                    block += "\r\n";
                    block += '<' + '!--{';
                    block += '/' + 'block';
                    block += '}-->';
                    block += "\r\n";
                }else if(rel == 'cms__article_one'){
                    block += '<' + '!--{';
                    block += 'block model="\\cms\\_article" method="one"';

                    block += ' param="' + $("#block-" + rel + " input[name='txtParam']").val() + '"';
                    block += ' var="' + $("#block-" + rel + " input[name='txtVar']").val() + '"';
                    block += '}-->';
                    block += "\r\n";
                    block += "{lang admin.ilinei.frame_parser.view.article.block.content}";
                    block += "\r\n";
                    block += '<' + '!--{';
                    block += '/' + 'block';
                    block += '}-->';
                    block += "\r\n";
                }

                var content = $('#txt_content').get(0);
                content.value = content.value.substr(0, content.selectionStart) + block + content.value.substring(content.selectionStart, content.value.length);

                $('#modal_dialog').modal('hide').remove();
            });
        }});
    }
</script>

<!--{template /module/admin/view/foot}-->